package behavioral_pattern.command_pattern;

import behavioral_pattern.command_pattern.comand.Command;
import behavioral_pattern.command_pattern.concrete_command.ChangeChannelCommand;
import behavioral_pattern.command_pattern.concrete_command.TurnOffCommand;
import behavioral_pattern.command_pattern.concrete_command.TurnOnCommand;
import behavioral_pattern.command_pattern.invoker.Control;
import behavioral_pattern.command_pattern.receiver.Tv;

public class Test {
    public static void main(String[] args) {
        // 定义命令接受者
        Tv tv = new Tv();
        // 开机命令
        Command turnOn = new TurnOnCommand(tv);
        // 关机命令
        Command turnOff = new TurnOffCommand(tv);
        //切换频道命令
        int channel = 1;
        Command changeChannel  = new ChangeChannelCommand(tv,channel);
        Control control = new Control(turnOn,turnOff,changeChannel);
        control.controlOn();
        control.controlOff();
        control.controlChannel();

    }
}
